package com.example.hospitalapp;

import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import java.util.List;

public class MedicalRecordActivity extends AppCompatActivity {

    private RecyclerView recyclerView;
    private MedicalRecordAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_medical_record);

        recyclerView = findViewById(R.id.recyclerViewMedicalRecords);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));

        // 获取传递过来的多个病历信息
        List<MedicalRecord> medicalRecords = (List<MedicalRecord>) getIntent().getSerializableExtra("medical_records");

        if (medicalRecords != null && !medicalRecords.isEmpty()) {
            // 创建适配器并设置给RecyclerView
            adapter = new MedicalRecordAdapter(this, medicalRecords);
            recyclerView.setAdapter(adapter);
        } else {
            Toast.makeText(this, "没有病历信息", Toast.LENGTH_SHORT).show();
        }
    }
}
